const express = require("express");
const path = require('path')
const app = express();
const homeRouter = require("./src/router");
const ejsRouter = require("./src/ejs");

// create application/json parser
// var jsonParser = bodyParser.json();

// create application/x-www-form-urlencoded parser


app.use((req, res, next) => {
  // const referer = req.get("referer");
  // console.log(referer, '相当于路由守卫判断');
  next();
});
// app.get('/login', (req, res) => {
//   res.send('我是测试')
// })
app.use(homeRouter);
app.use(ejsRouter);

// 静态资源引入路径
app.use(express.static(__dirname + "/"));
// ejs文件路径引入
app.set('views', path.resolve(__dirname, './src/views'))
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html')

app.listen(3000, () => {
  console.log("server is running...");
});
